package algotithm.leetcode.twopoint.test345;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/4-15:26
 */
class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        String s = "leetcode";
        String str = solution.reverseVowels(s);
        System.out.println(str);
    }

    public String reverseVowels(String s) {
        int i = 0, j = s.length() - 1;
        char[] c = s.toCharArray();
        while (i < j) {
            if( isVo(c[i]) ) {
                i++;
                continue;
            }
            if (isVo(c[j])) {
                j--;
                continue;
            }
            char tmp = c[i];
           c[i] = c[j];
           c[j] = tmp;
           i++;
           j--;

        }
        return String.valueOf(c);
    }

    public boolean isVo(char a) {
        // false代表是元音字母，true代表不是元音字母
        switch(a) {
            case 'a':
            case 'e':
            case 'i':
            case 'o':
            case 'u':
            case 'A':
            case 'E':
            case 'I':
            case 'O':
            case 'U':
                return false;
            default:
                return true;
        }

    }
}
